package com.sample.base.ui.activity

import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.widget.Toolbar
import com.loyal.kit.TimeUtil
import com.loyal.helper.UIHelper
import com.sample.base.R
import com.sample.base.base.BaseActivity
import com.sample.base.databinding.ActivityToolbarMenuBinding

class ToolbarMenuActivity : BaseActivity() {
    private val binding by lazy { ActivityToolbarMenuBinding.inflate(layoutInflater) }
    private lateinit var toolbar: Toolbar

    override fun setLayoutOrView() {
        setContentView(binding.root)
    }

    override fun afterOnCreate() {
        toolbar = findViewById(R.id.toolbar)
        toolbar.title = "Toolbar-Menu"
        setSupportActionBar(toolbar)
        binding.toast.setOnClickListener {
            val text = UIHelper.getInputText(binding.edit)
            UIHelper.toastShort(this, "$text:${TimeUtil.getDateTime()}")
        }
    }

    override fun onCreateOptionsMenu(menu: Menu): Boolean {
        menuInflater.inflate(R.menu.menu_muti, menu)
        return true
    }

    override fun onOptionsItemSelected(item: MenuItem): Boolean {
        when (item.itemId) {
            R.id.menu_test1 -> return true
        }
        return super.onOptionsItemSelected(item)
    }
}